package com.ppc.controller.employer;

import com.ppc.dto.EmployerClaimPageQueryDTO;
import com.ppc.result.PageResult;
import com.ppc.result.Result;
import com.ppc.service.EmployerClaimService;
import com.ppc.vo.EmployerClaimDetailVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * 雇主申诉相关接口
 *
 * @author LENOVO
 * @date 2023/12/20
 */
@RestController
@RequestMapping("/employer/claim")
@Slf4j
@Api(tags = "雇主申诉相关接口")
public class EmployerClaimController {

  @Autowired
  EmployerClaimService employerClaimService;

  /**
   * 雇主分页查询申诉订单
   *
   * @param employerClaimPageQueryDTO
   * @return
   */
  @GetMapping("/page")
  @ApiOperation(value = "雇主分页查询申诉")
  public Result<PageResult> pageQuery(EmployerClaimPageQueryDTO employerClaimPageQueryDTO) {
    log.info("雇主分页查询订单申诉：{}", employerClaimPageQueryDTO);
    PageResult pageResult;
    pageResult = employerClaimService.claimPageQuery(employerClaimPageQueryDTO);
    return Result.success(pageResult);
  }


  /**
   * @param taskId
   * @param claimType
   * @param claimReason
   * @return {@link Result }
   * @description
   */
  @PostMapping
  @ApiOperation(value = "雇主创建申诉订单")
  public Result empCreateClaim(Long taskId, Integer claimType, String claimReason) {
    log.info("雇主创建申诉订单：{} {} {}", taskId, claimType, claimReason);
    employerClaimService.createClaim(taskId, claimType, claimReason);
    return Result.success();
  }

  /**
   * @param claimId
   * @return {@link Result }<{@link EmployerClaimDetailVO }>
   * @description
   */
  @GetMapping("/detail")
  @ApiOperation(value = "雇主查看申诉的详细信息")
  public Result<EmployerClaimDetailVO> empCheckDetail(Long claimId) {
    log.info("雇主查看申诉的详细信息：{}", claimId);
    EmployerClaimDetailVO employerClaimDetailVO = employerClaimService.checkDetail(claimId);
    return Result.success(employerClaimDetailVO);
  }

  /**
   * @param page
   * @param pageSize
   * @return {@link Result }<{@link PageResult }>
   * @description
   */
  @PostMapping("/message")
  @ApiOperation(value = "雇主查看申诉消息")
  public Result<PageResult> employerCheckClaim(Integer page, Integer pageSize) {
    log.info("雇主查看申诉消息：{}");
    PageResult pageResult = employerClaimService.checkClaimMessage(page, pageSize);
    return Result.success(pageResult);
  }
}
